home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 24
/
Amiga Format AFCD24 (Feb 1998, Issue 108).iso
/
-in_the_mag-
/
emulation
/
-otherstuff-
/
amiganpi
/
src_blitz
/
interface.asc
< prev
next >
Wrap
Text File
|
1998-01-05
|
26KB
|
958 lines
; Interface code for AmigaNPI
; includes handling of CLI arguments, preference file
; or graphical MUI interface
gui_on.l=False ; assume started from CLI
pref_name$="AmigaNPI.prefs"
If Exists(pref_name$)
;do nothing, preference file is in default directory
Else
pref_name$="env:AmigaNPI.prefs"
EndIf
If Exists(pref_name$) ; read preferences file (if it exists)
If ReadFile(0,pref_name$)
FileInput 0
abort=False
Repeat
a$=Edit$(80)
Select a$
Case "Device"
device$=Edit$(80)
Case "Device_Unit"
device_unit=Val(Edit$(80))
Case "Device_Buffer"
device_buffer=Val(Edit$(80))
Case "Device_Speed"
device_speed=Val(Edit$(80))
Case "Device_Flags"
device_flags=Val(Edit$(80))
Case "Desktop_Wait"
desk_wait=Val(Edit$(80))
Case "Newton_Wait"
newt_wait=Val(Edit$(80))
Default
; read invalid line
abort=True
If NumPars>0
NPrint "ERROR - Invalid preferences file"
NPrint " May be obsolete version"
Else
dummy.l=Request("AmigaNPI ERROR","Invalid preferences file"+Chr$(10)+"May be obsolete version","Ok")
EndIf
End Select
Until Eof(0) OR (abort=True)
DefaultInput
CloseFile 0
EndIf
EndIf
If NumPars>0
; read CLI prefs, assume started from CLI
; actually, there is a specific command called `FromCLI' for this purpose...
NPrint "AmigaNPI 1.4"
NPrint ""
If Par$(1)="?"
; user is asking for help
NPrint "AmigaNPI PackageFile [device [device_unit [bps [flags [buffer size]]]]]"
NPrint ""
NPrint "Default for optional parameters is "
NPrint " devs:serial.device 0 38400 148 64"
NPrint "Unless `AmigaNPI.prefs' exists in the current directory or ENV:"
NPrint ""
NPrint "Flags - 128 - Disable Xon/Xoff"
NPrint " - 64 - Enable EOF checking"
NPrint " - 32 - Enable shared mode"
NPrint " - 16 - Enable high speed mode"
NPrint " - 8 - Break command waits for buffer empty"
NPrint " - 4 - use RTS/CTS"
NPrint " - 2 - Select odd parity (otherwise use even)"
NPrint " - 1 - Enable parity checking"
NPrint ""
NPrint "`AmigaNPI ?' results in this message being output"
NPrint "`AmigaNPI' opens a graphical interface (MUI 3.8)"
NPrint ""
NPrint "Amiga conversions and modification by David Fong (1997)"
NPrint "Written by Filip R. Zawadiak (1997)"
NPrint ""
NPrint "This program is free software; you can redistribute it"
NPrint "and/or modify it according to the terms of the GNU General"
NPrint "Public Licence as published by the Free Software Foundation"
NPrint ""
NPrint "This program is distributed in the hope that it will be"
NPrint "useful but WITHOUT ANY WARRANTY; without even the implied"
NPrint "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the"
NPrint "GNU General Public Licence for more details."
NPrint ""
NPrint "Note that this program can only load files with"
NPrint "the .pkg extension. It cannot upload .hqx files"
NPrint "or Stuffit (.sit) files"
End ; don't continue
EndIf
package$=Par$(1)
If NumPars>1
device$=Par$(2)
If NumPars>2
device_unit=Val(Par$(3))
If NumPars>3
device_speed=Val(Par$(4))
If NumPars>4
device_flags=Val(Par$(5))
If NumPars>5
device_buffer=Val(Par$(6))
EndIf
EndIf
EndIf
EndIf
EndIf
gui_on=False
Goto skip_mui ;skip all the MUI setup!
Else
; assume started from WB
; open up a MUI interface in any case
gui_on=True
EndIf
; now set up the MUI interface
DEFTYPE.l
CNIF #cli_only=0
#ASL_TitleText=$80080001
#ASL_InitialFile=$80080008
#ASL_InitialDrawer=$80080009
#ASL_InitialPattern=$8008000a
#ASL_flags1=$80080014
#ASL_AcceptPattern=$8008003e
#ASL_TitleText=$80080001
MUIApplicationTitle "AmigaNPI 1.4"
MUIApplicationVersion "$VER: AmigaNPI 1.4 (28/Dec/97)"
MUIApplicationCopyright "David Fong"
MUIApplicationAuthor "David Fong"
MUIApplicationDescription "Newton Package Installer"
MUIApplicationBase "AmigaNPI"
MUILabel 1,"Wait time (Amiga)",#MUIO_Label_LeftAligned
MUILabel 2,"Wait time (Newton)",#MUIO_Label_LeftAligned
MUIAddTags 3,#MUIA_Numeric_Default,20
MUINumericButton 3,"%ld seconds",5,60
MUIAddTags 4,#MUIA_Numeric_Default,5
MUINumericButton 4,"%ld seconds",5,60
MUIAddObjVGroup 5,1:MUIAddObjVGroup 5,2
MUIAddObjVGroup 6,3:MUIAddObjVGroup 6,4
MUICreateVGroup 5:MUICreateVGroup 6
MUIAddObjHGroup 7,5:MUIAddObjHGroup 7,6
MUICreateHGroup 7
MUILabel 8,"Serial device",#MUIO_Label_LeftAligned
MUIAddTags 9,#MUIA_Frame,#MUIV_Frame_String
MUIString 9,"devs:serial.device",80
MUIPopButton 45,#MUII_PopFile
MUIAddTags 10,#MUIA_Popstring_String,MUIObjLoc(9)
MUIAddTags 10,#ASL_InitialPattern,Null("#?.device")
MUIAddTags 10,#ASL_InitialDrawer,Null("devs:")
MUIAddTags 10,#ASL_InitialFile,Null("serial.device")
MUIAddTags 10,#ASL_flags1,1
MUIAddTags 10,#ASL_TitleText,Null("serial.device")
MUIAddTags 10,#MUIA_Popstring_Button,MUIObjLoc(45)
MUINewObject 10,"Popasl.mui",0
MUILabel 11,"Serial unit",#MUIO_Label_LeftAligned
MUIAddTags 12,#MUIA_Frame,#MUIV_Frame_String
MUIAddTags 12,#MUIA_Weight,300
MUIAddTags 12,#MUIA_String_Accept,Null("0123456789")
MUIString 12,"0",10
MUILabel 15,"Buffer size",#MUIO_Label_LeftAligned
MUIAddTags 16,#MUIA_Frame,#MUIV_Frame_String
MUIAddTags 16,#MUIA_Weight,300
MUIAddTags 16,#MUIA_String_Accept,Null("0123456789")
MUIString 16,"",10
MUILabel 13,"Speed",#MUIO_Label_LeftAligned
MUIAddTags 14,#MUIA_Frame,#MUIV_Frame_String
MUIAddTags 14,#MUIA_Weight,300
MUIAddTags 14,#MUIA_String_Accept,Null("0123456789")
MUIString 14,"",10
MUIAddTags 17,#MUIA_Group_Columns,2
MUIAddTags 17,#Child,MUIObjLoc(8),#Child,MUIObjLoc(10)
MUIAddTags 17,#Child,MUIObjLoc(11),#Child,MUIObjLoc(12)
MUIAddTags 17,#Child,MUIObjLoc(15),#Child,MUIObjLoc(16)
MUIAddTags 17,#Child,MUIObjLoc(13),#Child,MUIObjLoc(14)
MUINewObject 17,"Group.mui",0
MUICycle 18,Chr$(27)+"cNo parity",Chr$(27)+"cEven parity",Chr$(27)+"COdd parity"
MUICheckMark 19,0:MUICheckMark 20,0
MUICheckMark 21,0:MUICheckMark 22,1
MUICheckMark 23,0:MUICheckMark 24,1
MUILabel 25,"Xon/Xoff",#MUIO_Label_LeftAligned
MUILabel 26,"EOF mode",#MUIO_Label_LeftAligned
MUILabel 27,"Shared mode",#MUIO_Label_LeftAligned
MUILabel 28,"High speed",#MUIO_Label_LeftAligned
MUILabel 29,"Queued break",#MUIO_Label_LeftAligned
MUILabel 30,"RTS/CTS",#MUIO_Label_LeftAligned
MUILabel 31,"Parity",#MUIO_Label_LeftAligned
MUIAddTags 36,#MUIA_Group_Columns,4
MUIAddTags 36,#Child,MUIObjLoc(25),#Child,MUIObjLoc(19)
MUIAddTags 36,#Child,MUIObjLoc(26),#Child,MUIObjLoc(20)
MUIAddTags 36,#Child,MUIObjLoc(27),#Child,MUIObjLoc(21)
MUIAddTags 36,#Child,MUIObjLoc(28),#Child,MUIObjLoc(22)
MUIAddTags 36,#Child,MUIObjLoc(29),#Child,MUIObjLoc(23)
MUIAddTags 36,#Child,MUIObjLoc(30),#Child,MUIObjLoc(24)
MUINewObject 36,"Group.mui",0
MUIAddTags 37,#MUIA_InputMode,#MUIV_InputMode_RelVerify
MUISimpleButton 37,Chr$(27)+"cSave serial prefs"
MUIAddTags 38,#MUIA_InputMode,#MUIV_InputMode_RelVerify
MUISimpleButton 38,Chr$(27)+"cExit serial prefs"
MUIAddTags 39,#MUIA_Weight,200
MUINewObject 39,"Area.mui",0
MUIAddObjHGroup 40,31:MUIAddObjHGroup 40,18
MUIAddObjHGroup 40,39
MUICreateHGroup 40
MUIAddObjVGroup 41,17:MUIAddObjVGroup 41,36:MUIAddObjVGroup 41,40
MUICreateVGroup 41
MUIAddObjPage 42,41:MUIAddObjPage 42,7
MUICreatePage 42,"Serial device","Wait times"
MUIAddObjVGroup 43,42:MUIAddObjVGroup 43,37:MUIAddObjVGroup 43,38
MUICreateVGroup 43
MUICreateWindow 44,"Preferences","PREF",43
MUIAddTags 50,#MUIA_InputMode,#MUIV_InputMode_RelVerify
MUISimpleButton 50,Chr$(27)+"cPreferences"
MUIAddTags 51,#MUIA_InputMode,#MUIV_InputMode_RelVerify
MUISimpleButton 51,Chr$(27)+"cInstall package"
MUIAddTags 52,#MUIA_Frame,#MUIV_Frame_String
MUIString 52,"",80
MUIPopButton 57,#MUII_PopFile
MUIAddTags 53,#ASL_InitialPattern,Null("#?.pkg")
MUIAddTags 53,#ASL_flags1,1
MUIAddTags 53,#ASL_TitleText,Null("Select a package")
MUIAddTags 53,#MUIA_Popstring_String,MUIObjLoc(52)
MUIAddTags 53,#MUIA_Popstring_Button,MUIObjLoc(57)
MUINewObject 53,"Popasl.mui",0
MUIAddTags 54,#MUIA_Frame,#MUIV_Frame_Group
MUIAddTags 54,#MUIA_FrameTitle,Null("Package to install")
MUIAddObjHGroup 54,53
MUICreateHGroup 54
MUIAddObjVGroup 55,54:MUIAddObjVGroup 55,50:MUIAddObjVGroup 55,51
MUICreateVGroup 55
MUIAddTags 56,#MUIA_Window_Width,300
MUICreateWindow 56,"Amiga Newton Package Installer","MAIN",55
MUILabel 100,"Status:",#MUIO_Label_LeftAligned
MUIAddTags 101,#MUIA_Frame,#MUIV_Frame_Text
MUIAddTags 101,#MUIA_Weight,400
MUIAddTags 101,#MUIA_Text_Contents,Null("")
MUINewObject 101,"Text.mui",0
MUIAddObjHGroup 102,100:MUIAddObjHGroup 102,101
MUICreateHGroup 102
MUILabel 103,"Newton ID",#MUIO_Label_LeftAligned
MUILabel 104,"Manufacturer ID",#MUIO_Label_LeftAligned
MUILabel 105,"Machine type",#MUIO_Label_LeftAligned
MUILabel 106,"ROM version",#MUIO_Label_LeftAligned
MUILabel 107,"ROM stage",#MUIO_Label_LeftAligned
MUILabel 108,"RAM size",#MUIO_Label_LeftAligned
MUILabel 109,"Screen height",#MUIO_Label_LeftAligned
MUILabel 110,"Screen width",#MUIO_Label_LeftAligned
MUILabel 111,"Update version",#MUIO_Label_LeftAligned
MUILabel 112,"Object version",#MUIO_Label_LeftAligned
MUILabel 113,"Int store sig",#MUIO_Label_LeftAligned
MUILabel 114,"Vert resolution",#MUIO_Label_LeftAligned
MUILabel 115,"Horz resolution",#MUIO_Label_LeftAligned
MUILabel 116,"Screen depth",#MUIO_Label_LeftAligned
MUILabel 117,"Newton owner name",#MUIO_Label_LeftAligned
For i=118 To 131
MUIAddTags i,#MUIA_Text_Contents,Null(String$(" ",10))
MUIAddTags i,#MUIA_FixWidthTxt,Null("0xFFFFFFFF")
MUINewObject i,"Text.mui",0
Next i
MUIAddTags 132,#MUIA_Frame,#MUIV_Frame_Text
MUIAddTags 132,#MUIA_Text_Contents,Null("")
MUINewObject 132,"Text.mui",0
MUIAddObjVGroup 133,103:MUIAddObjVGroup 133,104
MUIAddObjVGroup 133,105:MUIAddObjVGroup 133,106
MUIAddObjVGroup 133,107:MUIAddObjVGroup 133,108
MUIAddObjVGroup 133,113
MUICreateVGroup 133
MUIAddTags 134,#MUIA_Frame,#MUIV_Frame_Text
MUIAddObjVGroup 134,118:MUIAddObjVGroup 134,119
MUIAddObjVGroup 134,120:MUIAddObjVGroup 134,121
MUIAddObjVGroup 134,122:MUIAddObjVGroup 134,123
MUIAddObjVGroup 134,128
MUICreateVGroup 134
MUIAddObjVGroup 135,109:MUIAddObjVGroup 135,110
MUIAddObjVGroup 135,111:MUIAddObjVGroup 135,112
MUIAddObjVGroup 135,114:MUIAddObjVGroup 135,115
MUIAddObjVGroup 135,116
MUICreateVGroup 135
MUIAddTags 136,#MUIA_Frame,#MUIV_Frame_Text
MUIAddObjVGroup 136,124:MUIAddObjVGroup 136,125
MUIAddObjVGroup 136,126:MUIAddObjVGroup 136,127
MUIAddObjVGroup 136,129:MUIAddObjVGroup 136,130
MUIAddObjVGroup 136,131
MUICreateVGroup 136
MUIAddObjHGroup 137,133:MUIAddObjHGroup 137,134
MUIAddObjHGroup 137,135:MUIAddObjHGroup 137,136
MUICreateHGroup 137
MUIAddObjVGroup 138,137
MUIAddObjVGroup 138,117
MUIAddObjVGroup 138,132
MUICreateVGroup 138
MUIAddTags 139,#MUIA_Gauge_Horiz,1
MUIAddTags 139,#MUIA_Frame,#MUIV_Frame_Gauge
MUIAddTags 139,#MUIA_Gauge_InfoText,Null("0 of 0 bytes")
MUINewObject 139,"Gauge.mui",0
MUIAddTags 140,#MUIA_InputMode,#MUIV_InputMode_RelVerify
MUISimpleButton 140,Chr$(27)+"cAbort"
MUIAddObjVGroup 141,102:MUIAddObjVGroup 141,139
MUIAddObjVGroup 141,138:MUIAddObjVGroup 141,140
MUICreateVGroup 141
MUIAddTags 142,#MUIA_Window_Width,250
MUICreateWindow 142,"Uploading package","UPLP",141
MUIAddSubWindow 44
MUIAddSubWindow 56
MUIAddSubWindow 142
CEND
;note that #AbortTransfer needs to be defined for the purposes
;of procedure `GetByte', even if cli_only is set to 1
#OpenSerialPrefs=512
#LoadNewPackage=513
#AbortTransfer=514
#CloseSerialPrefs=515
#SaveSerialPrefs=516
CNIF #cli_only=0
If MUICreateApplication
MUIApplicationObj 150
lf$=Chr$(10)
dummy$="AmigaNPI 1.4"+lf$+lf$+"Converted and modifed for the Amiga by David Fong (1997)"+lf$
dummy$=dummy$+"Written by Filip R. Zawadiak (1997)"+lf$+lf$
dummy$=dummy$+"This program is free software; you can redistribute it"+lf$
dummy$=dummy$+"and/or modify it according to the terms of the GNU General"+lf$
dummy$=dummy$+"Public Licence as published by the Free Software Foundation"+lf$+lf$
dummy$=dummy$+"This program is distributed in the hope that it will be useful"+lf$
dummy$=dummy$+"but WITHOUT ANY WARRANTY; without even the implied"+lf$
dummy$=dummy$+"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."+lf$
dummy$=dummy$+"See the GNU General Public Licence for more details."
dummy.l=Request("AmigaNPI",dummy$,"OK")
MUINotify 56,#MUIA_Window_CloseRequest,1,150,#MUIM_Application_ReturnID,#MUIV_Application_ReturnID_Quit
MUINotify 50,#MUIA_Pressed,0,150,#MUIM_Application_ReturnID,#OpenSerialPrefs
MUINotify 51,#MUIA_Pressed,0,150,#MUIM_Application_ReturnID,#LoadNewPackage
MUINotify 140,#MUIA_Pressed,0,150,#MUIM_Application_ReturnID,#AbortTransfer
MUINotify 142,#MUIA_Window_CloseRequest,1,150,#MUIM_Application_ReturnID,#AbortTransfer
MUINotify 44,#MUIA_Window_CloseRequest,1,150,#MUIM_Application_ReturnID,#CloseSerialPrefs
MUINotify 38,#MUIA_Pressed,0,150,#MUIM_Application_ReturnID,#CloseSerialPrefs
MUINotify 37,#MUIA_Pressed,0,150,#MUIM_Application_ReturnID,#SaveSerialPrefs
MUIOpenWindow 56
MUICloseWindow 44
MUICloseWindow 142
; now set various gadgets according to prefs
MUISet 9,#MUIA_String_Contents,&device$
MUISet 12,#MUIA_String_Contents,Null(Str$(device_unit))
MUISet 14,#MUIA_String_Contents,Null(Str$(device_speed))
MUISet 16,#MUIA_String_Contents,Null(Str$(device_buffer))
If (device_flags&128)
MUISet 19,#MUIA_Selected,False ;note that if bit 7 is set, then xon/xoff is NOT selected
Else
MUISet 19,#MUIA_Selected,1
EndIf
If (device_flags&64)
MUISet 20,#MUIA_Selected,1
Else
MUISet 20,#MUIA_Selected,False
EndIf
If (device_flags&32)
MUISet 21,#MUIA_Selected,1
Else
MUISet 21,#MUIA_Selected,False
EndIf
If (device_flags&16)
MUISet 22,#MUIA_Selected,1
Else
MUISet 22,#MUIA_Selected,False
EndIf
If (device_flags&8)
MUISet 23,#MUIA_Selected,1
Else
MUISet 23,#MUIA_Selected,False
EndIf
If (device_flags&4)
MUISet 24,#MUIA_Selected,1
Else
MUISet 24,#MUIA_Selected,False
EndIf
Select (device_flags&3)
Case 0
MUISet 18,#MUIA_Cycle_Active,0
Case 1
MUISet 18,#MUIA_Cycle_Active,1
Case 3
MUISet 18,#MUIA_Cycle_Active,2
Default
;in the case of `2', there must in fact be an error
End Select
MUISet 3,#MUIA_Numeric_Value,desk_wait
MUISet 4,#MUIA_Numeric_Value,newt_wait
Else
dummy.l=Request("Error window","Unable to open MUI interface","OK")
End
EndIf
Function GetFlags{}
m.l=0:flags.l=0
m=MUIGet(19,#MUIA_Selected)
flags+(1-m)*128 ;note that this bit is set if xon/xoff is NOT wanted
m=MUIGet(20,#MUIA_Selected)
flags+m*64
m=MUIGet(21,#MUIA_Selected)
flags+m*32
m=MUIGet(22,#MUIA_Selected)
flags+m*16
m=MUIGet(23,#MUIA_Selected)
flags+m*8
m=MUIGet(24,#MUIA_Selected)
flags+m*4
m=MUIGet(18,#MUIA_Cycle_Active)
Select m
Case 0
; don't set any parity bits
Case 1
flags+1
Case 2
flags+3
Default
; must be an error, actually
End Select
Function Return flags
End Function
Function get_gui_args{}
SHARED package$,device$,device_unit,device_buffer,device_speed,device_flags,desk_wait,newt_wait,pref_name$
DEFTYPE.l *m,mm
running=True
signal.l=0
While(running) ;Main loop
a.l=MUIWaitEvent
Select a ;Is there a signal ???
Case #MUIV_Application_ReturnID_Quit ;Quit ?
running=False
Case #OpenSerialPrefs
MUIOpenWindow 44
Case #CloseSerialPrefs
MUICloseWindow 44
Case #LoadNewPackage
*m=MUIGet(52,#MUIA_String_Contents)
package$=Peek$(*m)
*m=MUIGet(9,#MUIA_String_Contents)
device$=Peek$(*m)
*m=MUIGet(12,#MUIA_String_Contents)
device_unit=Val(Peek$(*m))
*m=MUIGet(14,#MUIA_String_Contents)
device_speed=Val(Peek$(*m))
*m=MUIGet(16,#MUIA_String_Contents)
device_buffer=Val(Peek$(*m))
; now get flags
device_flags=GetFlags{}
desk_wait=MUIGet(3,#MUIA_Numeric_Value)
newt_wait=MUIGet(4,#MUIA_Numeric_Value)
Function Return True ; upload package (return to main loop)
Case #SaveSerialPrefs
If WriteFile(0,pref_name$)
FileOutput 0
*m=MUIGet(9,#MUIA_String_Contents)
NPrint "Device":NPrint Peek$(*m)
*m=MUIGet(12,#MUIA_String_Contents)
NPrint "Device_Unit":NPrint Peek$(*m)
*m=MUIGet(16,#MUIA_String_Contents)
NPrint "Device_Buffer":NPrint Peek$(*m)
*m=MUIGet(14,#MUIA_String_Contents)
NPrint "Device_Speed":NPrint Peek$(*m)
; now get flags
NPrint "Device_Flags":NPrint GetFlags{}
mm=MUIGet(3,#MUIA_Numeric_Value)
NPrint "Desktop_Wait":NPrint mm
mm=MUIGet(4,#MUIA_Numeric_Value)
NPrint "Newton_Wait":NPrint mm
CloseFile 0
If pref_name$="env:AmigaNPI.prefs"
dummy.l=CopyFile("env:AmigaNPI.prefs","envarc:AmigaNPI.prefs")
EndIf
DefaultOutput
Else
; Couldn't open file for writing
If pref_name$="AmigaNPI.prefs"
dummy$="Unable to write AmigaNPI.prefs"+Chr$(10)+"to default directory"+Chr$(10)+Chr$(10)
dummy$="Try to write to env:"+Chr$(10)+"on next attempt?"
dummy.l=Request("Error window",dummy$,"Yes|No")
If dummy=1
pref_name$="env:AmigaNPI.prefs"
dummy.l=Request("Notify window","Please try saving prefs again...","OK")
EndIf
Else
dummy.l=Request("Error window","Unable to write"+Chr$(10)+"to env:AmigaNPI.prefs","OK")
EndIf
EndIf
Case 0
Delay_(1)
Default
NPrint a
End Select
Wend
MUIRemoveApplication ; Free the application
Function Return False ; return to main loop and quit
End Function
CEND
Statement Set_Status{a$}
CNIF #cli_only=0
DEFTYPE.l *m
*m=MUIGet(101,#MUIA_Text_Contents)
If Peek$(*m)<>a$ Then MUISet 101,#MUIA_Text_Contents,&a$
CEND
End Statement
Statement Set_Gauge{a.l}
CNIF #cli_only=0
SHARED package_length
p.l=a*100/package_length
b$=Str$(a)+" of "+Str$(package_length)+" bytes"
MUISet 139,#MUIA_Gauge_Current,p
MUISet 139,#MUIA_Gauge_InfoText,&b$
CEND
End Statement
Statement Notify_Waiting{}
CNIF #cli_only=0
SHARED gui_on
If gui_on=True
MUISet 139,#MUIA_Gauge_Current,0 ; set gauge status to 0
MUISet 139,#MUIA_Gauge_InfoText,Null("0 of 0 bytes")
dummy$="" ; various gadgets set to null
MUISet 118,#MUIA_Text_Contents,&dummy$:MUISet 119,#MUIA_Text_Contents,&dummy$
MUISet 120,#MUIA_Text_Contents,&dummy$:MUISet 121,#MUIA_Text_Contents,&dummy$
MUISet 122,#MUIA_Text_Contents,&dummy$:MUISet 123,#MUIA_Text_Contents,&dummy$
MUISet 124,#MUIA_Text_Contents,&dummy$:MUISet 125,#MUIA_Text_Contents,&dummy$
MUISet 126,#MUIA_Text_Contents,&dummy$:MUISet 127,#MUIA_Text_Contents,&dummy$
MUISet 128,#MUIA_Text_Contents,&dummy$:MUISet 129,#MUIA_Text_Contents,&dummy$
MUISet 130,#MUIA_Text_Contents,&dummy$:MUISet 131,#MUIA_Text_Contents,&dummy$
MUISet 132,#MUIA_Text_Contents,&dummy$
Set_Status{"Waiting"}
MUIOpenWindow 142
Else
CEND
Print "Waiting..."
CNIF #cli_only=0
EndIf
CEND
End Statement
Statement Notify_Connecting{}
CNIF #cli_only=0
SHARED gui_on
If gui_on=True
Set_Status{"Connecting"}
Else
CEND
NPrint "Connecting"
CNIF #cli_only=0
EndIf
CEND
End Statement
Statement Notify_rtdk{}
CNIF #cli_only=0
SHARED gui_on
If gui_on=True
Set_Status{"Request to dock received"}
Else
CEND
Print "Request to dock received..."
CNIF #cli_only=0
EndIf
CEND
End Statement
Statement Notify_dock{}
CNIF #cli_only=0
SHARED gui_on
If gui_on=True
Set_Status{"Docking initiated"}
Else
CEND
NPrint "Docking initiated"
CNIF #cli_only=0
EndIf
CEND
End Statement
Statement Notify_name{a.l,b.l}
; a contains the addresss of the received frame, b is the frame's length
CNIF #cli_only=0
SHARED gui_on
CEND
name$=""
ii=a+16+Peek.l(a+16)+4+1 ; start address, plus beginning of kdNewtonname
; plus the length kdNewtonname plus what is
; possibly the length of the string (including null byte)
; and then add one (since the string is in Unicode, which
; for English strings results in 00xx,00xx words)
Repeat
z=Peek.b(ii)
If (z>=32) AND (z<=127) Then name$=name$+Chr$(z)
ii+2
Until ((ii-a)>b) OR z=0
uid$="0x"+Hex$(Peek.l(a+20)):mnid$="0x"+Hex$(Peek.l(a+24))
mac$=Str$(Peek.l(a+28)):romv$=Str$(Peek.l(a+32))
roms$=Str$(Peek.l(a+36)):rams$=Str$(Peek.l(a+40))
scrh$=Str$(Peek.l(a+44)):scrw$=Str$(Peek.l(a+48))
sysv$=Str$(Peek.l(a+52)):objv$=Str$(Peek.l(a+56))
isig$="0x"+Hex$(Peek.l(a+60)):vres$=Str$(Peek.l(a+64))
hres$=Str$(Peek.l(a+68)):sdpt$=Str$(Peek.l(a+72))
CNIF #cli_only=0
If gui_on=True
Set_Status{"Newton name received"}
MUISet 132,#MUIA_Text_Contents,&name$
MUISet 118,#MUIA_Text_Contents,&uid$
MUISet 119,#MUIA_Text_Contents,&mnid$
MUISet 120,#MUIA_Text_Contents,&mac$
MUISet 121,#MUIA_Text_Contents,&romv$
MUISet 122,#MUIA_Text_Contents,&roms$
MUISet 123,#MUIA_Text_Contents,&rams$
MUISet 124,#MUIA_Text_Contents,&scrh$
MUISet 125,#MUIA_Text_Contents,&scrw$
MUISet 126,#MUIA_Text_Contents,&sysv$
MUISet 127,#MUIA_Text_Contents,&objv$
MUISet 128,#MUIA_Text_Contents,&isig$
MUISet 129,#MUIA_Text_Contents,&vres$
MUISet 130,#MUIA_Text_Contents,&hres$
MUISet 131,#MUIA_Text_Contents,&sdpt$
Else
CEND
NPrint "Newton name received...",name$
NPrint "Newton Unique ID : ",uid$
NPrint "Manufacturer ID : ",mnid$
NPrint "Machine type : ",mac$
NPrint "ROM version : ",romv$
NPrint "ROM stage : ",roms$
NPrint "RAM size : ",rams$
NPrint "Screen height : ",scrh$
NPrint "Screen width : ",scrw$
NPrint "System update : version ",sysv$
NPrint "Object system : version ",objv$
NPrint "Int store sig : ",isig$
NPrint "Vert resolution : ",vres$
NPrint "Horz resolution : ",hres$
NPrint "Screen depth : ",sdpt$
CNIF #cli_only=0
EndIf
CEND
End Statement
Statement Notify_timeoutset{}
CNIF #cli_only=0
SHARED gui_on
If gui_on=True
Set_Status{"Timeout set"}
Else
CEND
Print "Timeout set..."
CNIF #cli_only=0
EndIf
CEND
End Statement
Statement Notify_resultreceived{}
CNIF #cli_only=0
SHARED gui_on
If gui_on=True
Set_Status{"Result received"}
Else
CEND
NPrint "Result received"
CNIF #cli_only=0
EndIf
CEND
End Statement
Statement Notify_loading{a$}
CNIF #cli_only=0
SHARED gui_on
If gui_on=True
; do nothing
Else
CEND
Print "Loading ",a$,", "
CNIF #cli_only=0
EndIf
CEND
End Statement
Statement Notify_filelength{a.l}
CNIF #cli_only=0
SHARED gui_on,package_length
package_length=a
If gui_on=True
;do nothing, calculations are made later (since Gauge_max current limit is 16 bit)
Else
CEND
NPrint a.l," bytes."
CNIF #cli_only=0
EndIf
CEND
End Statement
Statement Notify_transferring{}
CNIF #cli_only=0
SHARED gui_on
If gui_on=True
Set_Status{"Transferring package"}
Else
CEND
NPrint "Transferring package"
CNIF #cli_only=0
EndIf
CEND
End Statement
Statement Notify_progress{a.l}
CNIF #cli_only=0
SHARED gui_on
If gui_on=True
Set_Status{"Transferring package"} ; this is time wasteful, but status may have been set to error notification
Set_Gauge{a}
Else
CEND
Print a.l,"..."
CNIF #cli_only=0
EndIf
CEND
End Statement
Statement Notify_padding{}
CNIF #cli_only=0
SHARED gui_on
If gui_on=True
Set_Status{"Padding file"} ; a GUI user will probably never see this message as it flashes by!
Else
CEND
NPrint ""
NPrint "WARNING - package file length is incorrect"
NPrint "...padding file with extra zeros."
CNIF #cli_only=0
EndIf
CEND
End Statement
Statement Notify_finished{}
CNIF #cli_only=0
SHARED gui_on
If gui_on=True
Set_Status{"Transfer complete"}
Else
CEND
NPrint ""
Print "Package sent..."
CNIF #cli_only=0
EndIf
CEND
End Statement
Statement Notify_disconnecting{}
CNIF #cli_only=0
SHARED gui_on
If gui_on=True
Set_Status{"Disconnecting"}
Else
CEND
Print "Sent disconnect..."
CNIF #cli_only=0
EndIf
CEND
End Statement
Statement Notify_timeout{}
CNIF #cli_only=0
SHARED gui_on
If gui_on=True
Set_Status{"ERROR - Timeout"}
dummy.l=Request("Error Window","ERROR - Timeout","OK")
Else
CEND
NPrint ""
NPrint "Timeout - Newton is not responding"
CNIF #cli_only=0
EndIf
CEND
End Statement
Statement Notify_disconnected{}
CNIF #cli_only=0
SHARED gui_on
If gui_on=True
Set_Status{"Disconnected"}
MUICloseWindow 142
Else
CEND
NPrint "Disconnected"
CNIF #cli_only=0
EndIf
CEND
End Statement
Statement Notify_nofile{}
CNIF #cli_only=0
SHARED gui_on
If gui_on=True
dummy.l=Request("Error Window","ERROR - Could not open file","OK")
Else
CEND
NPrint "Error - could not open input file"
CNIF #cli_only=0
EndIf
CEND
End Statement
Statement Notify_noserial{}
CNIF #cli_only=0
SHARED gui_on
If gui_on=True
dummy.l=Request("Error Window","ERROR - Could not open serial device","OK")
Else
CEND
NPrint "Error - could not open serial device"
CNIF #cli_only=0
EndIf
CEND
End Statement
Statement Notify_BadCRC{a$,b$}
CNIF #cli_only=0
SHARED gui_on
If gui_on=True
Set_Status{"Bad CRC"}
Else
CEND
NPrint "Bad CRC - Received - ",a$,", Expected - ",b$
CNIF #cli_only=0
EndIf
CEND
End Statement
Statement Notify_BadFrame{}
CNIF #cli_only=0
SHARED gui_on
If gui_on=True
Set_Status{"Bad Frame"}
Else
CEND
NPrint "Invalid Frame"
CNIF #cli_only=0
EndIf
CEND
End Statement
Statement Notify_NewtonRejectsFrame{}
CNIF #cli_only=0
SHARED gui_on
If gui_on=True
Set_Status{"Newton rejects frame"}
Else
CEND
Print "...NEWTON REJECTS DATA FRAME..."
CNIF #cli_only=0
EndIf
CEND
End Statement
Function GetByte{}
CNIF #cli_only=0
SHARED gui_on
CEND
SHARED device_unit,desk_wait
; returns -1 if timeout
; returns -2 if Abort button pushed
; currently CTRL-C is not supported
; waits at least 20 seconds
signal.l=0:b.l=0:a.w=0:our_wait.l=desk_wait*50
t.l=Timer
Repeat
If a<0 Then Delay_(1) ; wait if serial buffer was empty at last attempt to read
a=ReadSerial(device_unit)
CNIF #cli_only=0
If gui_on=True Then b=MUIEvent
CEND
Until (a>-1) OR ((Timer-t)>our_wait) OR (b=#AbortTransfer)
If b=#AbortTransfer Then a=-2
Function Return a
End Function
skip_mui:
; (this file is included as part of a larger program)